package com.cqw.domain;

import com.cqw.enums.ActivityStatusEnum;
import com.cqw.vo.ActivityVO;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Date;

/**
 * @Author: caoqingwen
 * @CreateTime: 2021-04-28 14:02
 * @Description: ${Description}
 */

/**
 * 活动表
 */
@ApiModel(value = "com-cqw-domain-Activity")
@Data
@AllArgsConstructor
public class Activity {
    /**
     * id
     */
    @ApiModelProperty(value = "id")
    private Long id;

    /**
     * 活动名称
     */
    @ApiModelProperty(value = "活动名称")
    private String activityName;

    /**
     * 活动链接
     */
    @ApiModelProperty(value = "活动链接")
    private String activityUrl;

    /**
     * 活动开始时间
     */
    @ApiModelProperty(value = "活动开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    /**
     * 活动结束时间
     */
    @ApiModelProperty(value = "活动结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;

    /**
     * 活动类型：1普通活动，2抽奖活动
     */
    @ApiModelProperty(value = "活动类型：1普通活动，2抽奖活动")
    private Integer type;

    /**
     * 活动状态：1编辑中,2已发布
     */
    @ApiModelProperty(value = "活动状态：1编辑中,2已发布")
    private Integer status;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    private String remark;

    /**
     * 新建时间
     */
    @ApiModelProperty(value = "新建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    /**
     * 新建人
     */
    @ApiModelProperty(value = "新建人")
    private Long createBy;

    /**
     * 修改时间
     */
    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    /**
     * 修改人
     */
    @ApiModelProperty(value = "修改人")
    private Long updateBy;


    public Activity() {
    }


    public Activity(ActivityVO activityVO) {
        this.id = activityVO.getId();
        this.activityName = activityVO.getActivityName();
        this.activityUrl = activityVO.getActivityUrl();
        this.startTime = activityVO.getStartTime();
        this.endTime = activityVO.getEndTime();
        this.type = activityVO.getType();
        this.status = activityVO.getStatus() == null ? ActivityStatusEnum.editing.getCode() : activityVO.getStatus();
        this.remark = activityVO.getRemark();
        this.createTime = new Date();
        this.updateTime = new Date();
    }
}